package spring.angularjs.services;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.validation.Validator;

import spring.angularjs.dao.HistoryDAO;
import spring.angularjs.dao.RoleDAO;
import spring.angularjs.dao.StatusDAO;
import spring.angularjs.dao.UserInfoDAO;
import spring.angularjs.domain.History;
import spring.angularjs.domain.Role;
import spring.angularjs.domain.Status;
import spring.angularjs.domain.Userinfo;
import spring.angularjs.domain.json.UserTemp;

@Service
public class ServicesImpl implements Services {

	@Autowired
	private UserInfoDAO userInfoDAO;
	
	@Autowired
	private HistoryDAO historyDAO;
	
	@Autowired
	private RoleDAO roleDAO;
	
	@Autowired
	private StatusDAO statusDAO;
	
	@Override
	@Transactional
	public Userinfo getUserInfo(String loginId) {
		return userInfoDAO.getUserInfo(loginId);
	}
	
	@Override
	@Transactional
	public UserTemp getUserTest(String loginId) {
		return userInfoDAO.getUserTest(loginId);
	}

	@Override
	@Transactional
	public List<Userinfo> userInfos() {
		return userInfoDAO.userInfos();
	}

	@Override
	@Transactional
	public boolean save(Userinfo userInfo) {
		userInfoDAO.save(userInfo);
		return true;
	}
	
	@Override
	@Transactional
	public boolean update(Userinfo userInfo) {
		userInfoDAO.update(userInfo);
		return true;
	}
	
	@Override
	@Transactional
	public boolean checkLoginId(String loginId) {
		return userInfoDAO.checkLoginId(loginId);
	}

	@Override
	@Transactional
	public List<Userinfo> userNomal() {
		return userInfoDAO.userNomal();
	}

	@Override
	@Transactional
	public List<Userinfo> usernew() {
		return userInfoDAO.usernew();
	}

	@Override
	@Transactional
	public List<Userinfo> useractive() {
		return userInfoDAO.useractive();
	}

	@Override
	@Transactional
	public List<Userinfo> userdisable() {
		return userInfoDAO.userdisable();
	}
	
	@Override
	@Transactional
	public Userinfo getUserAuthentication(String loginId) {
		return userInfoDAO.getUserAuthentication(loginId);
	}

	@Override
	@Transactional
	public int addHistory(History history) {
		int id = historyDAO.addHistory(history);
		return id;
	}

	@Override
	@Transactional
	public History getHistory(int id) {
		return historyDAO.getHistory(id);
	}

	@Override
	@Transactional
	public boolean saveOrUpdate(History history) {
		historyDAO.saveOrUpdate(history);
		return true;
	}

	@Override
	@Transactional
	public List<History> histories() {
		return historyDAO.histories();
	}
	
	@Override
	@Transactional
	public Role getRole(String roleid) {
		Role role = roleDAO.getRole(roleid);
		return role;
	}
	
	@Override
	@Transactional
	public Status getStatus(String statusid) {
		Status status = statusDAO.getStatus(statusid);
		return status;
	}

}
